OstreeMutableTree: Refactor: Add `parent` pointer
authorWilliam Manley <will@williammanley.net>
Mon, 25 Jun 2018 20:53:23 +0000 (21:53 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 29 Jun 2018 21:31:08 +0000 (21:31 +0000)
commit5b0dd1002e29d6ea7a768a66b7fee92c27dd1bf8
tree5d5cbbcb05825d1d9b2a41dc947af4611cb6ba0c
parentf2e71c60ecd6c46c5c54d521c6dd23f339d7c67b
OstreeMutableTree: Refactor: Add `parent` pointer

This implements a TODO item from
`ostree_mutable_tree_get_contents_checksum`.  We now no-longer invalidate
the dirtree contents checksum at `get_contents_checksum` time - we
invalidate it when the mtree is modified.  This is implemented by keeping
a pointer to the parent directory in each `OstreeMutableTree`.  This gives
us stronger invariants on `contents_checksum`.

For even stronger guarantees about invariants we could make
`ostree_repo_write_mtree` or similar a member of `OstreeMutableTree` and
remove `ostree_mutable_tree_set_metadata_checksum`.

I think I've fixed a bug here too.  We now invalidate parent's contents
checksum when our metadata checksum changes, whereas we didn't before.

Closes: #1655
Approved by: cgwalters
src/libostree/ostree-mutable-tree.c